﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.ComponentModel;
using BigLotterySyndicate.Classes;

namespace BigLotterySyndicate.Secured.Controls
{
    [DefaultProperty("CalendarValue")]
    [ToolboxData("<{0}:CalendarControl runat=server></{0}:CalendarControl>")]
    [ValidationProperty("CalendarValue")]
    public partial class CalendarControl : BaseUserControl
    {
        [Bindable(true)]
        public string CalendarValue
        {
            get { return this.txtCalendarValue.Text; }

            set {

                if (value == "01/01/0001 00:00")
                    this.txtCalendarValue.Text = "";
                else
                this.txtCalendarValue.Text = value; }
        }

        public string TabIndex
        {
            get {
                
                    return this.txtCalendarValue.TabIndex.ToString();
                
            }
            set { this.txtCalendarValue.TabIndex = short.Parse(value); }
        }

        public string CssClass
        {
            get
            {

                return this.txtCalendarValue.CssClass.ToString();

            }
            set { this.txtCalendarValue.CssClass = value; }
        }

        public string Style
        {
            set
            {
                if (!String.IsNullOrEmpty(value))
                    this.txtCalendarValue.Attributes.Add("style", value);
            }
        }

        public bool ShowTime
        {
            get;
            set;
        }
        
        protected void Page_Load(object sender, EventArgs e)
        {
            
        }

        private string DateFormat
        {
            get {
                if (ShowTime)
                    return "dd/MM/yyyy HH:ss";
                else
                    return "dd MMM yyyy";
            
            }
        }

        protected string PrintSelectedDate()
        {
            if (this.CalendarValue == "" || this.CalendarValue == "01/01/0001 00:00")
                    return "";
            else
            return this.CalendarValue;
        }

        public string PrintTextId()
        {
            return this.txtCalendarValue.ClientID;
        }

        public string PrintShowTime()
        {
            if (ShowTime)

                return "true";
            else
                return "false";
        }
    }
}